import request from '@/utils/request';

/**
 * 用户管理分页查询
 */
export function UserPageFunc(currentPage, pageSize, name) {
  return request({
    url: '/v1/users/page',
    method: 'get',
    params: {
      currentPage,
      pageSize,
      name
    }
  });
}

/**
 * 根据ID查询用户
 */
export function UserGetIdFunc(id) {
  return request({
    url: '/v1/users/',
    method: 'get',
    params: {
      id
    }
  });
}

/**
 * 分组获取所有用户
 */
export function getUserByRole() {
  return request({
    url: 'v1/roles/users',
    method: 'get'
  });
}
/**
 * 根据ID删除用户
 */
export function UserDelIdFunc(id) {
  return request({
    url: '/v1/users/' + id,
    method: 'delete'
  });
}

/**
 * 修改用户密码
 */
export function UserChangePsdFunc(id, newPassword, password) {
  return request({
    url: '/v1/users/password',
    method: 'put',
    data: {
      id,
      newPassword,
      password
    }
  });
}

/**
 * 修改用户
 */
export function UserChangeFunc(id, realName, roleIdList, status, username) {
  return request({
    url: '/v1/users/' + id,
    method: 'put',
    data: {
      id,
      realName,
      roleIdList,
      status,
      username
    }
  });
}

/**
 * 增加用户
 */
export function UserAddFunc(password, realName, roleIdList, status, username) {
  return request({
    url: '/v1/users',
    method: 'post',
    data: {
      password,
      realName,
      roleIdList,
      status,
      username
    }
  });
}

/**
 * 获取所有角色
 */
export function UserGetRoleListFunc() {
  return request({
    url: '/v1/roles',
    method: 'get'
  });
}

/**
 * 根据用户ID获取角色ID
 */
export function UserGetRoleIdFunc(id) {
  return request({
    url: '/v1/users/' + id + '/roles',
    method: 'get'
  });
}
